package com.itheima.controller;

import com.itheima.pojo.Emp;
import com.itheima.pojo.LoginInfo;
import com.itheima.pojo.Result;
import com.itheima.servise.EmpServise;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class LoginController {
    @Autowired
    private EmpServise empServise;
    // 员工登陆
    @PostMapping("/login")
    public Result login(@RequestBody Emp emp){
        log.info("员工登陆用户信息:{}", emp);
        LoginInfo login = empServise.login(emp);
        if (login != null){
            return Result.success(login);
        }
        return Result.error("用户名或密码错误,请重新录入");
    }
}
